package com.macro.mall.demo;

import java.util.Arrays;

public class InsertSort {
    public static void main(String[] args) {
        int []a =new int[]{123,23,31232,442,5,52,13,13,23} ;
        a=insertSort(a);
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }
        Arrays.asList(a).stream().forEach(ints -> System.out.println(ints));
    }
    public static int[] insertSort(int[] a){
        for (int i = 1; i < a.length; i++) {
             int temp =a[i];
             int j;
            for (j = i; j >0&&a[j-1]>temp ; j--) {
                a[j]=a[j-1];
            }
            a[j]=temp;
        }
        return a;
    }

}
